﻿using System;
using System.ComponentModel;

namespace HalconDotNet
{
	/// <summary>Represents an instance of a color space transformation lookup table</summary>
	// Token: 0x02000027 RID: 39
	public class HColorTransLUT : HHandle
	{
		// Token: 0x06000362 RID: 866 RVA: 0x0000883B File Offset: 0x00006A3B
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HColorTransLUT() : base(HHandleBase.UNDEF)
		{
		}

		// Token: 0x06000363 RID: 867 RVA: 0x00013F7F File Offset: 0x0001217F
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HColorTransLUT(IntPtr handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x06000364 RID: 868 RVA: 0x00013F8E File Offset: 0x0001218E
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HColorTransLUT(HHandle handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x06000365 RID: 869 RVA: 0x00013F9D File Offset: 0x0001219D
		private void AssertSemType()
		{
			base.AssertSemType("color_trans_lut");
		}

		// Token: 0x06000366 RID: 870 RVA: 0x00013FAA File Offset: 0x000121AA
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HColorTransLUT obj)
		{
			obj = new HColorTransLUT(HHandleBase.UNDEF);
			return obj.Load(proc, parIndex, err);
		}

		// Token: 0x06000367 RID: 871 RVA: 0x00013FC4 File Offset: 0x000121C4
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HColorTransLUT[] obj)
		{
			HTuple htuple;
			err = HTuple.LoadNew(proc, parIndex, err, out htuple);
			obj = new HColorTransLUT[htuple.Length];
			for (int i = 0; i < htuple.Length; i++)
			{
				obj[i] = new HColorTransLUT(HalconAPI.IsLegacyHandleMode() ? htuple[i].IP : htuple[i].H);
			}
			htuple.Dispose();
			return err;
		}

		/// <summary>
		///   Creates the look-up-table for transformation of an image from the RGB color space to an arbitrary color space.
		///   Modified instance represents: Handle of the look-up-table for color space transformation.
		/// </summary>
		/// <param name="colorSpace">Color space of the output image. Default: "hsv"</param>
		/// <param name="transDirection">Direction of color space transformation. Default: "from_rgb"</param>
		/// <param name="numBits">Number of bits of the input image. Default: 8</param>
		// Token: 0x06000368 RID: 872 RVA: 0x00014034 File Offset: 0x00012234
		public HColorTransLUT(string colorSpace, string transDirection, int numBits)
		{
			IntPtr proc = HalconAPI.PreCall(1579);
			HalconAPI.StoreS(proc, 0, colorSpace);
			HalconAPI.StoreS(proc, 1, transDirection);
			HalconAPI.StoreI(proc, 2, numBits);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Release the look-up-table needed for color space transformation.
		///   Instance represents: Handle of the look-up-table handle for the color space transformation.
		/// </summary>
		// Token: 0x06000369 RID: 873 RVA: 0x00014090 File Offset: 0x00012290
		public void ClearColorTransLut()
		{
			IntPtr proc = HalconAPI.PreCall(1577);
			base.Store(proc, 0);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Color space transformation using pre-generated look-up-table.
		///   Instance represents: Handle of the look-up-table for the color space transformation.
		/// </summary>
		/// <param name="image1">Input image (channel 1).</param>
		/// <param name="image2">Input image (channel 2).</param>
		/// <param name="image3">Input image (channel 3).</param>
		/// <param name="imageResult2">Color-transformed output image (channel 2).</param>
		/// <param name="imageResult3">Color-transformed output image (channel 3).</param>
		/// <returns>Color-transformed output image (channel 1).</returns>
		// Token: 0x0600036A RID: 874 RVA: 0x000140C4 File Offset: 0x000122C4
		public HImage ApplyColorTransLut(HImage image1, HImage image2, HImage image3, out HImage imageResult2, out HImage imageResult3)
		{
			IntPtr proc = HalconAPI.PreCall(1578);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, image1);
			HalconAPI.Store(proc, 2, image2);
			HalconAPI.Store(proc, 3, image3);
			HalconAPI.InitOCT(proc, 1);
			HalconAPI.InitOCT(proc, 2);
			HalconAPI.InitOCT(proc, 3);
			int num = HalconAPI.CallProcedure(proc);
			HImage result;
			num = HImage.LoadNew(proc, 1, num, out result);
			num = HImage.LoadNew(proc, 2, num, out imageResult2);
			num = HImage.LoadNew(proc, 3, num, out imageResult3);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(image1);
			GC.KeepAlive(image2);
			GC.KeepAlive(image3);
			return result;
		}

		/// <summary>
		///   Creates the look-up-table for transformation of an image from the RGB color space to an arbitrary color space.
		///   Modified instance represents: Handle of the look-up-table for color space transformation.
		/// </summary>
		/// <param name="colorSpace">Color space of the output image. Default: "hsv"</param>
		/// <param name="transDirection">Direction of color space transformation. Default: "from_rgb"</param>
		/// <param name="numBits">Number of bits of the input image. Default: 8</param>
		// Token: 0x0600036B RID: 875 RVA: 0x0001415C File Offset: 0x0001235C
		public void CreateColorTransLut(string colorSpace, string transDirection, int numBits)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(1579);
			HalconAPI.StoreS(proc, 0, colorSpace);
			HalconAPI.StoreS(proc, 1, transDirection);
			HalconAPI.StoreI(proc, 2, numBits);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}
	}
}
